QuickTime 4 API Documentation

3D Graphics Programming with QuickDraw 3D 1.5.4

Previous | QD3D Book | Overview | Chapter Contents | Next |

Blending Operations

A drawing engine may support a transparency blending function that determines the kind of transparency blending applied to a drawing context when combining new ("source") pixels with the pixels already in a frame buffer ("destination"). You specify an engine's transparency blending function by assigning a value to its kQATag_Blend state variable. The default value of this variable for a draw context that supports transparency blending is kQABlend_PreMultiply .

In the equations below, the factors s , s , s , and s represent the alpha, red, green and blue components of a source pixel; the factors d , d , d , and d represent the alpha, red, green and blue components of a destination pixel.

#define kQABlend_PreMultiply                        0
#define kQABlend_Interpolate                        1
#define kQABlend_OpenGL                             2

Constant descriptions

kQABlend_PreMultiply
The drawing engine uses a premultiplied blending function. The components of a pixel written to the frame buffer are computed using these equations:
In general, you should use the premultiplied blending function for rendering shaded transparent 3D primitives (such as triangles). The premultiplied function does not scale the source color components by the alpha value s ; as a result, this function allows a transparent object to have a specular highlight value that is greater than its alpha channel value. For example, a sheet of glass might allow 99% of the light behind it to pass though (indicating an alpha channel value of 0.01). However, that same sheet of glass might have a specular highlight value much greater than 0.01. The premultiplied function allows the drawing engine to render this object correctly.
kQABlend_Interpolate
The drawing engine uses an interpolated blending function. The components of a pixel written to the frame buffer are computed using these equations:
The interpolated blending function is not entirely suitable for rendering shaded transparent objects, but it is very effective for compositing bitmap images.
kQABlend_OpenGL
The drawing engine uses the OpenGL blending function determined by the values of the kQATagGL_BlendSrc and kQATagGL_BlendDest state variables. For complete information on OpenGL blending functions, consult the description of the glBlendFunc function in OpenGL Reference Manual . OpenGL blending functions are supported only by drawing engines that support the kQAOptional_OpenGL feature.

© 1997 Apple Computer, Inc.

Previous | QD3D Book | Overview | Chapter Contents | Next |